package ar.edu.caece.compiler.grammars.sample2.factories;

import ar.edu.caece.compiler.grammars.sample2.grammar.Lambda;
import ar.edu.caece.compiler.grammars.sample2.tokens.SampleGrammarSymbol;
import ar.edu.caece.compiler.grammars.sample2.tokens.SampleToken;
import ar.edu.caece.compiler.grammars.sample2.tokens.TokenVisitorInterface;
import ar.edu.caece.compiler.model.LexicalAnalyzer;

public class LambdaFactory extends AbstractTokenVisitorFactory{

	private static LambdaFactory INSTANCE;
	
	public LambdaFactory(LexicalAnalyzer analizadorLexico) {
		super(analizadorLexico);
	}

	public LambdaFactory() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public TokenVisitorInterface makeChainedVisitor(TokenVisitorInterface siguiente) throws Exception {
		
		return makeVisitor();
	}

	@Override
	public TokenVisitorInterface makeVisitor() throws Exception {
		
		return new TokenVisitorInterface() {

			@Override
			public SampleGrammarSymbol defaultCase(SampleToken llamador, SampleGrammarSymbol param)
					throws Exception {
				backToken();
				return Lambda.getInstance();
			}
			
		};

	}

	public static LambdaFactory getInstance() {
		if(INSTANCE==null) INSTANCE = new LambdaFactory();
		return INSTANCE;
	}

}
